﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Matrix_network.Code;

namespace Matrix_network
{
    public partial class SentMessage : System.Web.UI.Page
    {
        int id;
        int toId;
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpRequest r = Request;
            if (r.QueryString["toId"] != null)
            {
                toId = Int32.Parse(r.QueryString["toId"]);
                id = Int32.Parse(User.Identity.Name);
                MessagesDataSource mds = new MessagesDataSource();
                ToLabel.Text = "To" + " " + mds.getNameFromId(toId);
            }
            else { SendButton.Enabled = false; }
        }


        protected void SendButton_Click(object sender, EventArgs e)
        {
            new MessagesDataSource().sentMessage(id, toId, ResponseMsg.Text);
            Response.Redirect("~/Messages.aspx");
        }
    }
}